﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class AddCategory : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Label10.Visible = false;
        ManagementPayment m = new ManagementPayment();
        if (!IsPostBack)
        {
            DropDownList1.DataSource = m.GetSubCategory();
            DropDownList1.DataBind();
            LoadData();
        }
    }

    private void LoadData()
    {
        ManagementPayment m = new ManagementPayment();
        if (m.GetPaymentMethodID().Count==0)
        txtID.Text = "1";
        else
        txtID.Text = (m.GetPaymentMethodID().Last() + 1).ToString();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
       ManagementPayment m = new ManagementPayment();
     if (m.AddPaymentMethod(txtName.Text,Double.Parse(txtPrice.Text), txtNote.Text,Int32.Parse(DropDownList1.SelectedValue[0].ToString())))
     
         {
             LoadData();
            Label10.Visible = true;
            Label10.Text = "<span style='width: 200px;color:green;font-weight:bold;float: left;margin-left:10px;margin-bottom:15px;'>Add SuccerFully</span>";
     }else{
            LoadData();
              Label10.Visible = true;
              Label10.Text = "<span style='width: 200px;color:red;font-weight:bold;float: left;margin-left:10px;;margin-bottom:15px;'>Add Failed</span>";
     }
    }


    protected void DropDownList1_TextChanged(object sender, EventArgs e)
    {
        
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
       
    }
}